package com.hongkzh.www.mediaShop.controller;

import com.google.common.collect.Lists;
import com.hongkzh.www.conmon.BaseController;
import com.hongkzh.www.conmon.BusinessException;
import com.hongkzh.www.conmon.DateUtil;
import com.hongkzh.www.conmon.ReqResponse;
import com.hongkzh.www.mediaShop.service.MediaShopService;
import com.hongkzh.www.swagger.annotation.*;
import com.jfinal.kit.PropKit;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.upload.UploadFile;

import java.io.File;
import java.util.List;

/**
 * @author martins
 */
@Api(tag = "mediaShop", description = "自媒体电商")
public class MediaShopController extends BaseController {
    /**
     * 上传文件基础虚拟路径
     */
    public static final String USERFILES_BASE_URL = "/userfiles/1/images/hkUserProductImg/";


    MediaShopService mediaShopService = new MediaShopService();

    @ApiOperation(url = "/v1/mediaShop/saveProduct", tag = "mediaShop", httpMethod = "post", description = "添加商品")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "title", description = "商品名称", required = true, dataType = "string"),
            @Param(name = "isNew", description = "是否二手物 1是0不是", required = true, dataType = "string"),
            @Param(name = "imgSrc", description = "图片数组(第一张为主图)", required = true, dataType = "string"),
            @Param(name = "mediaCategoryId", description = "自媒体电商分类id", required = true, dataType = "string"),
            @Param(name = "userFreightId", description = "用户运费模板id(包邮为0)", required = true, dataType = "string"),
            @Param(name = "content", description = "商品详情", required = true, dataType = "string"),
            @Param(name = "model", description = "型号数组", required = true, dataType = "string"),
            @Param(name = "price", description = "价格数组", required = true, dataType = "string"),
            @Param(name = "num", description = "数量数组", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void saveProduct() {
        List<UploadFile> list = getFiles();
        getResponse().addHeader("Access-Control-Allow-Origin", "*");
        String loginUid = getAttr("loginUid");
        String mediaCategoryId = getPara("mediaCategoryId");
        String userFreightId = getPara("userFreightId");
        String title = getPara("title");
        String isNew = getPara("isNew");
        String content = getPara("content");
        String[] model = getParaValues("model");
        String[] price = getParaValues("price");
        Integer[] num = getParaValuesToInt("num");
        ReqResponse<String> r = new ReqResponse();
        String coverImgSrc = null;
        File file;
        List<String> imgs = Lists.newArrayList();
        for (UploadFile u : list
        ) {
            coverImgSrc = USERFILES_BASE_URL + DateUtil.FormatDateMMDD() + "/";
            coverImgSrc = getFilePath(coverImgSrc, u);
            imgs.add(coverImgSrc);
        }
        enhance(MediaShopService.class).saveProduct(imgs, loginUid, mediaCategoryId, userFreightId, title, content, model, price, num, isNew);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/updateProductByImg", tag = "mediaShop", httpMethod = "post", description = "修改商品带图片的")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "productId", description = "商品id", required = true, dataType = "string"),
            @Param(name = "title", description = "商品名称", required = true, dataType = "string"),
            @Param(name = "imgSrc", description = "图片数组(第一张为主图)", required = true, dataType = "string"),
            @Param(name = "mediaCategoryId", description = "自媒体电商分类id", required = true, dataType = "string"),
            @Param(name = "userFreightId", description = "用户运费模板id(包邮为0)", required = true, dataType = "string"),
            @Param(name = "content", description = "商品详情", required = true, dataType = "string"),
            @Param(name = "skuId", description = "skuId数组", required = true, dataType = "string"),
            @Param(name = "model", description = "型号数组", required = true, dataType = "string"),
            @Param(name = "price", description = "价格数组", required = true, dataType = "string"),
            @Param(name = "num", description = "数量数组", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void updateProductByImg() {
        List<UploadFile> list = getFiles();
        getResponse().addHeader("Access-Control-Allow-Origin", "*");
        String loginUid = getAttr("loginUid");
        String productId = getPara("productId");
        String mediaCategoryId = getPara("mediaCategoryId");
        String userFreightId = getPara("userFreightId");
        String title = getPara("title");
        String content = getPara("content");
        String[] skuId = getParaValues("skuId");
        String[] model = getParaValues("model");
        String[] price = getParaValues("price");
        Integer[] num = getParaValuesToInt("num");
        ReqResponse<String> r = new ReqResponse();
        String coverImgSrc = null;
        File file;
        List<String> imgs = Lists.newArrayList();
        for (UploadFile u : list
        ) {
            coverImgSrc = USERFILES_BASE_URL + DateUtil.FormatDateMMDD() + "/";
            coverImgSrc = getFilePath(coverImgSrc, u);
            imgs.add(coverImgSrc);
        }
        enhance(MediaShopService.class).updateProductByImg(imgs, loginUid, mediaCategoryId, userFreightId, title, content, model, price, num, skuId, productId);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/updateProduct", tag = "mediaShop", httpMethod = "post", description = "修改商品不带图片的")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "productId", description = "商品id", required = true, dataType = "string"),
            @Param(name = "title", description = "商品名称", required = true, dataType = "string"),
            @Param(name = "mediaCategoryId", description = "自媒体电商分类id", required = true, dataType = "string"),
            @Param(name = "userFreightId", description = "用户运费模板id(包邮为0)", required = true, dataType = "string"),
            @Param(name = "content", description = "商品详情", required = true, dataType = "string"),
            @Param(name = "skuId", description = "skuId数组", required = true, dataType = "string"),
            @Param(name = "model", description = "型号数组", required = true, dataType = "string"),
            @Param(name = "price", description = "价格数组", required = true, dataType = "string"),
            @Param(name = "num", description = "数量数组", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void updateProduct() {

        getResponse().addHeader("Access-Control-Allow-Origin", "*");
        String loginUid = getAttr("loginUid");
        String productId = getPara("productId");
        String mediaCategoryId = getPara("mediaCategoryId");
        String userFreightId = getPara("userFreightId");
        String title = getPara("title");
        String content = getPara("content");
        String[] skuId = getParaValues("skuId");
        String[] model = getParaValues("model");
        String[] price = getParaValues("price");
        Integer[] num = getParaValuesToInt("num");
        ReqResponse<String> r = new ReqResponse();
        enhance(MediaShopService.class).updateProduct(loginUid, mediaCategoryId, userFreightId, title, content, model, price, num, skuId, productId);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/freightList", tag = "mediaShop", httpMethod = "post", description = "运费列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "isSystem 1是系统模板不能删除 0否 " +
                            "  piece 件 money 价格 addPiece 增加件 addMoney 增加价格" +
                            "freightId 运费id name 名称 isExcept 1除以下城市之外 0否 provinceName 省份名称 provinceId 省份id" +
                            "sublist[freightId 运费id piece 件 money 价格 addPiece 增加件 addMoney 增加价格 areafreightId子运费id provinceName 省份名称 provinceId 省份id]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void freightList() {
        ReqResponse<List<Record>> r = new ReqResponse();
        String loginUid = getAttr("loginUid");
        List<Record> list = enhance(MediaShopService.class).freightList(loginUid);
        r.setData(list);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/deletefreight", tag = "mediaShop", httpMethod = "post", description = "删除运费")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "freightId", description = "运费id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void deletefreight() {
        ReqResponse<String> r = new ReqResponse();
        String loginUid = getAttr("loginUid");
        String freightId = getPara("freightId");
        mediaShopService.deletefreight(loginUid, freightId);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/deleteareafreight", tag = "mediaShop", httpMethod = "post", description = "删除子运费")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "areafreightId", description = "子运费id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void deleteareafreight() {
        ReqResponse<String> r = new ReqResponse();
        String loginUid = getAttr("loginUid");
        String areafreightId = getPara("areafreightId");
        mediaShopService.deleteareafreight(loginUid, areafreightId);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/savefreight", tag = "mediaShop", httpMethod = "post", description = "保存运费(增加和修改运费都使用这个)")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "freightId", description = "运费id 没有值就是增加 有值就是修改", required = false, dataType = "string"),
            @Param(name = "name", description = "名称", required = true, dataType = "string"),
            @Param(name = "isExcept", description = "1除以下城市之外 0否", required = true, dataType = "string"),
            @Param(name = "provinceId", description = "省份id 逗号隔开", required = true, dataType = "string"),
            @Param(name = "piece", description = "件", required = true, dataType = "string"),
            @Param(name = "money", description = "价格", required = true, dataType = "string"),
            @Param(name = "addPiece", description = "增加件", required = true, dataType = "string"),
            @Param(name = "addMoney", description = "增加价格", required = true, dataType = "string"),
            @Param(name = "areafreightId", description = "子运费id数组", required = true, dataType = "string"),
            @Param(name = "subprovinceId", description = "省份id数组 逗号隔开", required = true, dataType = "string"),
            @Param(name = "subpiece", description = "件数组", required = true, dataType = "string"),
            @Param(name = "submoney", description = "价格数组", required = true, dataType = "string"),
            @Param(name = "subaddPiece", description = "增加件数组", required = true, dataType = "string"),
            @Param(name = "subaddMoney", description = "增加价格数组", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void savefreight() {
        ReqResponse<String> r = new ReqResponse();
        String loginUid = getAttr("loginUid");
        String name = getPara("name");
        String freightId = getPara("freightId");
        String isExcept = getPara("isExcept");
        String provinceId = getPara("provinceId");
        String piece = getPara("piece");
        String money = getPara("money");
        String addPiece = getPara("addPiece");
        String addMoney = getPara("addMoney");
        String[] areafreightId = getParaValues("areafreightId");
        String[] subprovinceId = getParaValues("subprovinceId");
        String[] subaddMoney = getParaValues("subaddMoney");
        String[] subpiece = getParaValues("subpiece");
        String[] submoney = getParaValues("submoney");
        String[] subaddPiece = getParaValues("subaddPiece");
        mediaShopService.savefreight(loginUid, name, freightId, isExcept, provinceId, piece, money, addPiece, addMoney, areafreightId, subprovinceId, subpiece, submoney, subaddPiece, subaddMoney);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/addCart", tag = "mediaShop", httpMethod = "post", description = "加入购物车")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "shopId", description = "店铺id ", required = false, dataType = "string"),
            @Param(name = "mediaUserId", description = "自媒体用户", required = false, dataType = "string"),
            @Param(name = "productId", description = "产品id", required = true, dataType = "string"),
            @Param(name = "skuId", description = "skuid", required = true, dataType = "string"),
            @Param(name = "number", description = "数量", required = true, dataType = "string"),
            @Param(name = "isBuyNow", description = "是否立即购买[0-立即购买 1加入购物车]", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " cartCount 购物车数量 cartId 购物车id "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void addCart() {
        String loginUid = getAttr("loginUid");
        String shopId = getPara("shopId");
        String productId = getPara("productId");
        String skuId = getPara("skuId");
        String number = getPara("number");
        String mediaUserId = getPara("mediaUserId");
        String isBuyNow = getPara("isBuyNow");
        ReqResponse<Record> r = new ReqResponse();
        r.setData(enhance(MediaShopService.class).addCart(loginUid, shopId, productId, skuId, number, mediaUserId, "1", isBuyNow));
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/cartCount", tag = "mediaShop", httpMethod = "post", description = "购物车数量")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  购物车数量"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void cartCount() {
        String loginUid = getAttr("loginUid");
        ReqResponse<Integer> r = new ReqResponse();
        r.setData(mediaShopService.cartCount(loginUid, "1"));
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/updateCart", tag = "mediaShop", httpMethod = "post", description = "修改购物车数量")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "cartId", description = "购物车id", required = true, dataType = "string"),
            @Param(name = "number", description = "数量", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = ""),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void updateCart() {
        String loginUid = getAttr("loginUid");
        String cartId = getPara("cartId");
        String number = getPara("number");
        ReqResponse r = new ReqResponse();
        enhance(MediaShopService.class).updateCart(loginUid, cartId, number);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/deleteCartByid", tag = "mediaShop", httpMethod = "post", description = "删除购物车")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "cartId", description = "购物车id逗号隔开 ", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " 购物车数量 "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void deleteCartByid() {
        String loginUid = getAttr("loginUid");
        String cartId = getPara("cartId");
        ReqResponse<Integer> r = new ReqResponse();
        r.setData(enhance(MediaShopService.class).deleteCartByid(loginUid, cartId, "1"));
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/cartList", tag = "mediaShop", httpMethod = "post", description = "购物车列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "   headImg 头像  name 名称 shopId店铺id " +
                            "products 商品数[ colorName 颜色 productId 商品id currentTime  当前时间" +
                            " title 标题 limitTime 限制时间 number 购物车数量 productNumber 库存   specName 规格名称" +
                            "integral乐币 mediaUserId 自媒体用户id cartId 购物车id  imgSrc 商品图片 skuId ]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void cartList() {
        String loginUid = getAttr("loginUid");
        List<Record> list = mediaShopService.cartList(loginUid, "1");
        ReqResponse<List<Record>> r = new ReqResponse();
        r.setData(list);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/cartIsStorage", tag = "mediaShop", httpMethod = "post", description = "购物车是否加入储物箱")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "cartId", description = "购物车id", required = true, dataType = "string"),
            @Param(name = "state", description = "1 是0 否", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = ""),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void cartIsStorage() {
        String loginUid = getAttr("loginUid");
        String cartId = getPara("cartId");
        String state = getPara("state");
        enhance(MediaShopService.class).cartIsStorage(loginUid, cartId, state);
        ReqResponse r = new ReqResponse();

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/payOrder", tag = "mediaShop", httpMethod = "post", description = " 支付订单")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "ordersId", description = "订单id 逗号隔开", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void payOrder() {
        String loginUid = getAttr("loginUid");
        String ordersId = getPara("ordersId");
        ReqResponse<String> r = new ReqResponse();
        try {
            enhance(MediaShopService.class).payOrder(loginUid, ordersId);
        } catch (BusinessException e) {
            r.setMsg(e.getErrMsg());
            r.setCode(1);
            // System.out.println(e.getErrMsg());
            //e.printStackTrace();
        }
        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaShop/rechargePayOrder", tag = "mediaShop", httpMethod = "post", description = " 支付订单")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "ordersId", description = "订单id 逗号隔开", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void rechargePayOrder() {
        String loginUid = getAttr("loginUid");
        String ordersId = getPara("ordersId");
        ReqResponse<String> r = new ReqResponse();
        try {
            enhance(MediaShopService.class).rechargePayOrder(loginUid, ordersId);
        } catch (BusinessException e) {
            r.setMsg(e.getErrMsg());
            r.setCode(1);
            // System.out.println(e.getErrMsg());
            //e.printStackTrace();
        }
        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaShop/saveOrder", tag = "mediaShop", httpMethod = "post", description = "结算订单")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "cartId", description = "购物车id 数组", required = true, dataType = "string"),
            @Param(name = "addressId", description = "地址id", required = true, dataType = "string"),
            @Param(name = "skuProductCouponIdIsIntegral", description = "(skuId-productId-counponId-isIntegral)  数组  isIntegral 是否抵扣乐币 1是0否", required = false, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "countOffMoney 兑换现金 countOffsetCoin兑换乐币  ordersId 订单id 逗号隔开,allIntegral 现金合计 user [name 名称 headImg 头像 integral ] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void saveOrder() {
        getResponse().addHeader("Access-Control-Allow-Origin", "*");
        String loginUid = getAttr("loginUid");
        String[] cartIds = getParaValues("cartId");
        String addressId = getPara("addressId");
        String[] skuProductCouponId = getParaValues("skuProductCouponIdIsIntegral");
        ReqResponse<Record> r = new ReqResponse();
        try {
            r.setData(enhance(MediaShopService.class).saveOrder(loginUid, cartIds, addressId, skuProductCouponId));

        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getErrMsg());
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/rechargeOrder", tag = "mediaShop", httpMethod = "post", description = "自媒体-充值")
    @Params({
            @Param(name = "loginUid", description = "当前登录用户id", required = true, dataType = "string"),
            @Param(name = "integral", description = "充值的乐币数", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{orderNumber 订单号 ，money 人民币金额  }"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })

    public void rechargeOrder() {
        String loginUid = getAttr("loginUid");
        double integral = (Double.parseDouble(getPara("integral")));
//        int integral1 = new Double(integral).intValue();
        ReqResponse<Record> r = new ReqResponse();
        try {
            r.setData(enhance(MediaShopService.class).rechargeOrder(loginUid, integral));
        } catch (Exception e) {
            e.printStackTrace();
            r.setCode(1);

        }
        renderJson(r);
    }

    /* @ApiOperation(url = "/v1/mediaShop/changeAddress", tag = "mediaShop", httpMethod = "post",description = "预下单-更改收货地址")
     @Params({
             @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
             @Param(name = "cartId", description = "购物车id 数组", required = true, dataType = "string"),
             @Param(name = "addressId", description = "地址id", required = true, dataType = "string"),
     })
     @ApiResponses({
             @ApiResponse(code=200,message="成功",responseHeaders={
                     @ResponseHeader(name="code",description = " 0成功 1失败"),
                     @ResponseHeader(name="data",description = "freightIntegral 运费合计 productIntegral 商品合计费用 counIntegral 总计 "),
                     @ResponseHeader(name="msg",description = "失败原因") })
     })
     public void changeAddress() {
         String loginUid=getAttr("loginUid");
         String []cartIds=getParaValues("cartId");
         String addressId=getPara("addressId");
         ReqResponse<Record> r=new ReqResponse();

         r.setData(mediaShopService.changeAddress(loginUid,cartIds,addressId));
         renderJson(r);
     }*/
    @ApiOperation(url = "/v1/mediaShop/preorder", tag = "mediaShop", httpMethod = "post", description = "预下单")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "cartId", description = "购物车id 数组", required = true, dataType = "string"),
            @Param(name = "addressId", description = "地址id", required = false, dataType = "string"),
            @Param(name = "skuProductCouponIdIsIntegral", description = "(skuId-productId-counponId-isIntegral)  数组  isIntegral 是否抵扣乐币 1是0否", required = false, dataType = "string"),
    })

    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "address 地址[addressId 地址id  uid 用户id isDefault 1是默认地址0否 consignee收货人 phone 电话 address 详细地址 provinceId 省份id] " +
                            "freightIntegral 运费合计 productIntegral 商品合计费用 countegral 总计 userIntegral用户乐币 countOffsetCoin 总抵扣金额" +
                            "list[  headImg 头像  name 名称 mediaUserId mediaFreightIntegral 商家运费 " +
                            "products 商品数[ colorName 颜色 productId 商品id" +
                            " title 标题 limitTime 限制时间 number 数量   specName 规格名称" +
                            "integral乐币 mediaUserId 自媒体商户id shopId 商铺id cartId 购物车id  offsetCoin 抵扣乐币  imgSrc 商品图片 skuId couponId 优惠券id couponTitle优惠券折扣 couponCount 可用优惠券数量]]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void preorder() {
        getResponse().addHeader("Access-Control-Allow-Origin", "*");
        String loginUid = getAttr("loginUid");
        String addressId = getPara("addressId");
        String[] cartIds = getParaValues("cartId");
        String[] skuProductCouponId = getParaValues("skuProductCouponIdIsIntegral");
        ReqResponse<Record> r = new ReqResponse();

        /*if (StrKit.isBlank(addressId)) {
            r.setCode(1);
            r.setMsg("请先添加收货地址");
            renderJson(r);
        }*/

        try {
            r.setData(mediaShopService.preorder(loginUid, cartIds, addressId, skuProductCouponId));
        } catch (BusinessException e) {
            r.setCode(1);
            r.setMsg(e.getErrMsg());
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/orderProductCoupon", tag = "mediaShop", httpMethod = "post", description = "预订单产品优惠券")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "productId", description = "产品id", required = true, dataType = "string"),
    })

    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = " availableCoupons[couponId 优惠券id title 标题 imgSrc 商品图片 discount 折扣 beginTime开始时间 endTime结束时间 remarks pintegral  产品价格]"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void orderProductCoupon() {
        String loginUid = getAttr("loginUid");
        String productId = getPara("productId");
        ReqResponse<Record> r = new ReqResponse();
        r.setData(mediaShopService.orderProductCoupon(loginUid, productId));
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/userOrderList", tag = "mediaShop", httpMethod = "post", description = "订单列表")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "name", description = "内容", required = false, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
            @Param(name = "type", description = "类型 0全部订单 1等待付款 3待收货 7已完成 8 已取消 100 待分享", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "payIntegral 抵扣乐币 payMoney 支付现金 limitTime 支付倒计时 orderNumber 订单号  currentTime 当前时间 courier 快递公司 courierNumber 订单号" +
                            "state 订单状态 1 等待付款 2 确定订单   3 已支付  4 已发货 5 已收货 6 暂存储 7 已完成  8 已取消  9 已转售 10 已关闭 11乐币支付12现金支付 100待分享" +
                            " integral乐币 freightIntegral 运费乐币 mediaUserId 商户id name 商户名称 headImg 商户头像 subList 订单商品[colorName 颜色名称" +
                            "  orderNumber 订单号 title 标题 activityPrice活动价格 activityType 活动类型 1爆款 2 秒杀 3折扣 " +
                            "productId 商品id imgSrc 商品图 skuId  limitTime 支付限制时间 number  数量  discount 折扣  price 价格 " +
                            "specName规格名称 mediaUserId 商户id  integral 乐币 ] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void userOrderList() {
        String loginUid = getAttr("loginUid");
        String type = getPara("type");
        String name = getPara("name");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();
        Page<Record> record = mediaShopService.userOrderList(loginUid, type, pageNumber, name);
        r.setData(record);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaShop/userOrderInfo", tag = "mediaShop", httpMethod = "post", description = "订单详情")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "payIntegral 抵扣乐币 payMoney 支付现金 address 地址[addressId 地址id cityId 城市id areaId 区域id uid 用户id isDefault 1是默认地址0否 consignee收货人" +
                            "provinceName省份名称 cityName 城市名称areaName 区名称 phone 电话 address 详细地址 provinceId 省份id] " +
                            " limitTime 支付倒计时 orderNumber 订单号 createDate 下单时间 currentTime 当前时间" +
                            "deliverTime  发货时间 courier 快递公司 courierNumber 快递单号" +
                            "payTime 支付时间 payType 支付类型 1-乐币 2-现金  3-组合支付 sellTime 售出时间 confirmDate 成交时间" +

                            " integral乐币 freightIntegral 运费乐币 productIntegral 商品乐币 mediaUserId 商户id name 商户名称 headImg 商户头像 subList 订单商品[colorName 颜色名称" +
                            "  orderNumber 订单号 title 标题 activityPrice活动价格 activityType 活动类型 1爆款 2 秒杀 3折扣 " +
                            "productId 商品id imgSrc 商品图 skuId  limitTime 支付限制时间 number  数量  " +
                            "specName规格名称 mediaUserId 商户id  integral 乐币 " + " afterState 售后状态 10申请退款 20 取消退款 30 同意退款 40拒绝退款 " +
                            " 45退款完成50买家投诉 55买家取消投诉 " +
                            "60申请退货退款 65取消退货退款70同意退货退款 " +
                            "80拒绝退货退款 90退货退款完成100买家举证110卖家举证" +
                            "state 订单状态 1 等待付款 2 确定订单  " +
                            "3 已支付  4 已发货 5 已收货 6 暂存储 7 已完成  8 已取消  9 已转售 10 已关闭  11乐币支付12现金支付 100待分享]" +
                            "afterList 售后日志[name 名称 type 1进行中2完成3关闭  createDate时间 ] " + "isWithdraw 是否可提现 0-未提现 1-申请提现 2-已提现 3-未到提现时间" + "withMoney 提现金额" + "isWithdrawCash 1-已绑定银行卡 否则为未绑定银行卡"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void userOrderInfo() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<Record> r = new ReqResponse();
        Record record = mediaShopService.userOrderInfo(loginUid, orderNumber);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/userOrderRefund", tag = "mediaShop", httpMethod = "post", description = "订单申请退款")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "refundcontact", description = "退款联系人", required = true, dataType = "string"),
            @Param(name = "refundReason", description = "退款原因", required = true, dataType = "string"),
            @Param(name = "refundTelephone", description = "退款电话", required = true, dataType = "string"),
            @Param(name = "state", description = "1默认为添加2为修改", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void userOrderRefund() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        String refundcontact = getPara("refundcontact");
        String refundReason = getPara("refundReason");
        String refundTelephone = getPara("refundTelephone");
        String state = getPara("state");
        ReqResponse<String> r = new ReqResponse();
        enhance(MediaShopService.class).userOrderRefund(loginUid, orderNumber, refundcontact, refundReason, refundTelephone, state, "1");

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/canceluserOrderRefund", tag = "mediaShop", httpMethod = "post", description = "取消订单申请退款")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void canceluserOrderRefund() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<String> r = new ReqResponse();
        enhance(MediaShopService.class).canceluserOrderRefund(loginUid, orderNumber);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/canceluserOrderRefundAndGoods", tag = "mediaShop", httpMethod = "post", description = "取消退货退款")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void canceluserOrderRefundAndGoods() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<String> r = new ReqResponse();
        enhance(MediaShopService.class).canceluserOrderRefundAndGoods(loginUid, orderNumber);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/logisticsInformation", tag = "mediaShop", httpMethod = "post", description = "物流信息")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "courier", description = "快递公司", required = true, dataType = "string"),
            @Param(name = "courierNumber", description = "快递单号", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "{\"message\":\"ok\",\"status\":\"1\",\"state\":\"3\",\"data\":[{\"time\":\"2012-07-07 13:35:14\",\"context\":\"客户已签收\"},{\"time\":\"2012-07-07 09:10:10\",\"context\":\"离开 [北京_房山营业所_石景山营业厅] 派送中，递送员[温]，电话[]\"},{\"time\":\"2012-07-06 19:46:38\",\"context\":\"到达 [北京_房山营业所_石景山营业厅]\"},{\"time\":\"2012-07-06 15:22:32\",\"context\":\"离开 [北京_房山营业所_石景山营业厅] 派送中，递送员[温]，电话[]\"},{\"time\":\"2012-07-06 15:05:00\",\"context\":\"到达 [北京_房山营业所_石景山营业厅]\"},{\"time\":\"2012-07-06 13:37:52\",\"context\":\"离开 [北京_同城中转站] 发往 [北京_房山营业所_石景山营业厅]\"},{\"time\":\"2012-07-06 12:54:41\",\"context\":\"到达 [北京_同城中转站]\"},{\"time\":\"2012-07-06 11:11:03\",\"context\":\"离开 [北京运转中心_航空_驻站班组] 发往 [北京_同城中转站]\"},{\"time\":\"2012-07-06 10:43:21\",\"context\":\"到达 [北京运转中心_航空_驻站班组]\"},{\"time\":\"2012-07-05 21:18:53\",\"context\":\"离开 [福建_厦门支公司] 发往 [北京运转中心_航空]\"},{\"time\":\"2012-07-05 20:07:27\",\"context\":\"已取件，到达 [福建_厦门支公司]\"}]}"),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void logisticsInformation() {
        String courier = getPara("courier");
        String courierNumber = getPara("courierNumber");
        ReqResponse<String> r = new ReqResponse();
        String str = mediaShopService.logisticsInformation(courier, courierNumber);
        r.setData(str);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/canceluserOrder", tag = "mediaShop", httpMethod = "post", description = "取消订单")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void canceluserOrder() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<String> r = new ReqResponse();
        enhance(MediaShopService.class).canceluserOrder(loginUid, orderNumber);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/deleteuserOrder", tag = "mediaShop", httpMethod = "post", description = "删除订单")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void deleteuserOrder() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<String> r = new ReqResponse();
        enhance(MediaShopService.class).deleteuserOrder(loginUid, orderNumber);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/saveProductDetailImg", tag = "mediaShop", httpMethod = "post", description = "添加商品详情图片")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "imgSrc", description = "图片文件", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "文件路径"),
                    @ResponseHeader(name = "msg", description = "失败原因")})

    })
    public void saveProductDetailImg() {
        UploadFile uf = getFile("imgSrc");
        getResponse().addHeader("Access-Control-Allow-Origin", "*");

        ReqResponse<String> r = new ReqResponse();
        try {
            String coverImgSrc = USERFILES_BASE_URL + DateUtil.FormatDateMMDD() + "/";
            coverImgSrc = getFilePath(coverImgSrc, uf);
            //FileUtils.copyFileUsingFileChannels(uf.getFile(), file);
            r.setData(PropKit.get("fileServer") + coverImgSrc);
        } catch (Exception e) {
            e.printStackTrace();
            r.setCode(1);
        }
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/myAfterSale", tag = "mediaShop", httpMethod = "post", description = "售后退货")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "   orderNumber 订单号  currentTime 当前时间 " +
                            "   state 订单状态 1 等待付款 2 确定订单   3 已支付  4 已发货 5 已收货 6 暂存储 7 已完成  8 已取消  9 已转售 10 已关闭 11乐币支付12现金支付 100待分享" +
                            "  integral乐币 freightIntegral 运费乐币 mediaUserId 商户id name 商户名称 headImg 商户头像 subList 订单商品[colorName 颜色名称 " +
                            "   orderNumber 订单号 title 标题 activityPrice活动价格 activityType 活动类型 1爆款 2 秒杀 3折扣 " +
                            "  productId 商品id imgSrc 商品图 skuId  limitTime 支付限制时间 number  数量  " + " afterState 售后状态 10申请退款 20 取消退款 30 同意退款 40拒绝退款 " +
                            " 45退款完成50买家投诉 55买家取消投诉 " +
                            "60申请退货退款 65取消退货退款70同意退货退款 " +
                            "80拒绝退货退款 90退货退款完成100买家举证110卖家举证" +
                            "  specName规格名称 mediaUserId 商户id  integral 乐币 state 订单状态 1 等待付款 2 确定订单   " +
                            "   3 已支付  4 已发货 5 已收货 6 暂存储 7 已完成  8 已取消  9 已转售 10 已关闭 11乐币支付12现金支付 100待分享] "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void myAfterSale() {
        String loginUid = getAttr("loginUid");
        int pageNumber = getParaToInt("pageNumber");
        ReqResponse<Page<Record>> r = new ReqResponse();

        Page<Record> p = mediaShopService.myAfterSale(loginUid, pageNumber);
        r.setData(p);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/userOrderComplaint", tag = "mediaShop", httpMethod = "post", description = "买家订单投诉")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "complaintReason", description = "投诉原因", required = true, dataType = "string"),
            @Param(name = "complaintDesc", description = "投诉说明", required = true, dataType = "string"),
            @Param(name = "imgSrc", description = "图片数组", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void userOrderComplaint() {
        List<UploadFile> list = getFiles();
        getResponse().addHeader("Access-Control-Allow-Origin", "*");
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        String complaintReason = getPara("complaintReason");
        String complaintDesc = getPara("complaintDesc");

        List<String> imgs = Lists.newArrayList();

        String coverImgSrc = null;
        for (UploadFile u : list
        ) {
            coverImgSrc = USERFILES_BASE_URL + DateUtil.FormatDateMMDD() + "/";
            coverImgSrc = getFilePath(coverImgSrc, u);
            imgs.add(coverImgSrc);
        }
        ReqResponse<String> r = new ReqResponse();
        enhance(MediaShopService.class).userOrderComplaint(loginUid, orderNumber, complaintReason, imgs, complaintDesc);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/canceluserOrderComplaint", tag = "mediaShop", httpMethod = "post", description = "买家取消订单投诉")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),

    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void canceluserOrderComplaint() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<String> r = new ReqResponse();
        enhance(MediaShopService.class).canceluserOrderComplaint(loginUid, orderNumber);

        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaShop/userOrderRefundAfter", tag = "mediaShop", httpMethod = "post", description = "订单申请售后")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "refundcontact", description = "退款联系人", required = true, dataType = "string"),
            @Param(name = "refundReason", description = "退款原因", required = true, dataType = "string"),
            @Param(name = "type", description = "1退款2退货退款", required = true, dataType = "string"),
            @Param(name = "refundTelephone", description = "退款电话", required = true, dataType = "string"),
            @Param(name = "state", description = "1默认为添加2为修改", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void userOrderRefundAfter() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        String refundcontact = getPara("refundcontact");
        String refundReason = getPara("refundReason");
        String refundTelephone = getPara("refundTelephone");
        String type = getPara("type");
        String state = getPara("state");
        ReqResponse<String> r = new ReqResponse();
        enhance(MediaShopService.class).userOrderRefund(loginUid, orderNumber, refundcontact, refundReason, refundTelephone, state, type);

        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/returnLogistics", tag = "mediaShop", httpMethod = "post", description = "退货物流")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "courier", description = "快递公司", required = true, dataType = "string"),
            @Param(name = "courierNumber", description = "快递单号", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })
    public void returnLogistics() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        String courier = getPara("courier");
        String courierNumber = getPara("courierNumber");
        ReqResponse<Record> r = new ReqResponse();
        enhance(MediaShopService.class).returnLogistics(loginUid, orderNumber, courier, courierNumber);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/mediaShop/buyerProof", tag = "mediaShop", httpMethod = "post", description = "买家举证")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
            @Param(name = "buyerProof", description = "买家举证因", required = true, dataType = "string"),
            @Param(name = "buyerProofDesc", description = "买家举证说明", required = true, dataType = "string"),
            @Param(name = "imgSrc", description = "图片数组", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })

    public void buyerProof() {
        List<UploadFile> list = getFiles();
        getResponse().addHeader("Access-Control-Allow-Origin", "*");
        String loginUid = getAttr("loginUid");
        String buyerProof = getPara("buyerProof");
        String orderNumber = getPara("orderNumber");
        String buyerProofDesc = getPara("buyerProofDesc");
        List<String> imgs = Lists.newArrayList();
        String coverImgSrc = null;
        for (UploadFile u : list
        ) {
            coverImgSrc = USERFILES_BASE_URL + DateUtil.FormatDateMMDD() + "/";
            coverImgSrc = getFilePath(coverImgSrc, u);
            imgs.add(coverImgSrc);
        }
        ReqResponse<Record> r = new ReqResponse();
        enhance(MediaShopService.class).buyerProof(loginUid, orderNumber, buyerProof, imgs, buyerProofDesc);
        renderJson(r);
    }


    @ApiOperation(url = "/v1/mediaShop/confirmCollectGoods", tag = "mediaShop", httpMethod = "post", description = "确认收货")
    @Params({
            @Param(name = "loginUid", description = "当前用户id", required = true, dataType = "string"),
            @Param(name = "orderNumber", description = "订单号", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功", responseHeaders = {
                    @ResponseHeader(name = "code", description = " 0成功 1失败"),
                    @ResponseHeader(name = "data", description = "  "),
                    @ResponseHeader(name = "msg", description = "失败原因")})
    })

    public void confirmCollectGoods() {
        String loginUid = getAttr("loginUid");
        String orderNumber = getPara("orderNumber");
        ReqResponse<Record> r = new ReqResponse();
        enhance(MediaShopService.class).confirmCollectGoods(loginUid, orderNumber);
        renderJson(r);
    }
}
